﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using eTMS.Controllers.LyDoCamThiService;
using eTMS.Controllers;
using eTMS.Commons;
namespace eTMS.Controls{
   public class ComboBoxLyDoCamThi : ComboBoxBindingBase<LyDoCamThiEntity>
   {
		public ComboBoxLyDoCamThi(){
	    }
		//Bind data to txtLyDoCamThi
        public override void BindData(){
		    List<LyDoCamThiEntity>lsLyDoCamThi = new List<LyDoCamThiEntity>(LyDoCamThiController.ListLyDoCamThiStatic.ToArray());
			lsLyDoCamThi=FilterList(lsLyDoCamThi);
		    if(IsAddChooseItem){
				LyDoCamThiEntity eChooseItem = new LyDoCamThiEntity();
				eChooseItem.TenLyDo = Constants.CHOOSE_ITEM;
				lsLyDoCamThi.Insert(0,eChooseItem);
			}		
		    if(IsAddAllItem){
				LyDoCamThiEntity eChooseItem = new LyDoCamThiEntity();
				eChooseItem.TenLyDo = Constants.APP_ALL;
				lsLyDoCamThi.Insert(0,eChooseItem);
			}			
		    this.DisplayMember = "TenLyDo";
		    object currentSelected=this.SelectedValue;
		    this.ValueMember = "LyDoCamThi_ID";
		    this.DataSource = lsLyDoCamThi;
		    if(currentSelected==null){
				if(this.Items.Count>0){
					this.SelectedIndex=0;
				}
            }
            else{
					this.SelectedValue = currentSelected;
					if(this.SelectedValue==null){
						if(this.Items.Count>0){
						this.SelectedIndex=0;
					}
                }
            }
        }
	}
}
